<?php

/**
 * 微博抓取管理
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");

include_once($_SERVER["DOCUMENT_ROOT"] . "/include/user/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/mblog/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/tuijian/inc.php");


$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
		//页码
	cgi::get($g_cgival["p"], "p", 1);
	$g_cgival["p"] = intval($g_cgival["p"]);

	cgi::get($g_cgival["type"], "type", 0);
	$g_cgival["type"] = intval($g_cgival["type"]);
	
	cgi::get($g_cgival["status"], "status", 1);
	$g_cgival["status"] = string::un_html($g_cgival["status"]);
	
	cgi::get($g_cgival["show_type"], "show_type", "");
	$g_cgival["show_type"] = string::un_html($g_cgival["show_type"]);
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$g_cgival["pcount"] = 20;
	$g_show['status'] = $g_cgival["status"];
	$show_type = $g_cgival["show_type"];
	$db_tuijian_jiaodian = new db_tuijian_jiaodian();
	
	$db_user_fans_for_search = new db_user_fans_for_search();
	$list = $db_user_fans_for_search->admin_get_list($g_cgival["status"],$g_cgival["p"],$g_cgival["pcount"]);
	$count = $db_user_fans_for_search->admin_get_count($g_cgival["status"]);
	
	$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
	foreach($list as $key => $value)
	{
		$topic_info = $db_mblog_cron_topic_tag->get_mblog_cron_topic_tag_item_by_id($value["topic_id"]);
		$list[$key]["topic"] = $topic_info["topic"];
		
	}
	
	$g_show["count"] = $count;
	$g_show["list"] = $list;
	
	$max_page = page_bar::get_page_max($g_show["count"], $g_cgival["pcount"], $g_cgival["p"]);
	$page_bar_style = array(
			"curt"		=> $g_cgival["p"],
			"max"		=> $max_page,
			"key"		=> "p",
	);
	
	$g_show["page_bar"] = "<b>{$g_show["count"]}</b> 条记录&nbsp;&nbsp;第{$g_cgival["p"]}页&nbsp;共{$max_page}页&nbsp;" . page_bar::bar3($page_bar_style);
	
	
}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_list.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
		print_r($g_show);
	$smarty = p_get_smarty ();
	$smarty->assign ( 'g_show', $g_show );
	$smarty->display ( "mblog/user_fans_for_search_list.html" );
}

